<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function isPerfect(num) {
            var sum = 0;
            for (var i = 1; i < num; i++){
                if (num % i == 0){
                    sum += i;
                }
            }
            if (sum == num) {
                return console.log("该数为完美数");
            } else {
                return console.log("该数不是完美数");
            }
        }
        isPerfect(6);
        isPerfect(10);
        isPerfect(22);
    </script>
</head>
<body>
    
</body>
</html>